# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=nipe
pkgver=302.9e628df
pkgrel=5
pkgdesc='A script to make Tor Network your default gateway.'
groups=('blackarch' 'blackarch-defensive' 'blackarch-networking')
arch=('any')
url='https://github.com/GouveaHeitor/nipe'
license=('MIT')
depends=('perl' 'perl-switch' 'perl-json' 'perl-config-simple' 'perl-libwww')
makedepends=('git')
source=("git+https://github.com/GouveaHeitor/$pkgname.git"
        'Start.pm.patch')
sha512sums=('SKIP'
            '93e16636f60162c67b43814295aefecceea3e43a9875ecc3dc7cf5d12ab4db48ced3857a43c536a81bbdb89712bfd298d9ee0d430d5cd31767f39074f6fdf903')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  patch -p1 < Start.pm.patch
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec perl $pkgname.pl "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

